package com.sun.officeoa.service;

import com.sun.officeoa.bean.Employee;
import com.sun.officeoa.dao.EmployeeDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EmployeeService {

    @Resource
    private EmployeeDao employeeDao;

    private Employee loginUser;

    public Employee getLoginUser() {
        return loginUser;
    }
    public int updateEmpStatusById(int id, int status) {
        return employeeDao.updateEmpStatusById(id, status);
    }
    public List<Employee> getUnApproveaccount() {
        return employeeDao.getUnApproveaccount();
    }
    public int login(String username, String password) {
        int result = 3;//表示登录失败
        Employee loginEmp = employeeDao.login(username, password);
        if (loginEmp == null) {
            return result;
        }else{
            this.loginUser = loginEmp;
            return loginEmp.getStatus();
        }
    }
    public List<Employee> getEmpByDepId(int depId) {
        return employeeDao.getEmpByDepId(depId);
    }
    public int insert(Employee employee) {
        return employeeDao.insert(employee);
    }

    public List<Employee> searchEmp(String employeename,String username,int status,int page,int count){

        return employeeDao.searchEmp(employeename, username, status, page, count);
    }

    public int getCount(String employeename,String username,int status){

        return employeeDao.getCount(employeename,username,status);
    }

    public int updateUser(int emId,String password){
        return employeeDao.updateUser(emId,password);
    }


}
